import api from '../../api';
import { message } from 'antd';

export default {
  namespace: 'benchMarkM',
  state: {},
  effects: {
    // 获取基准列表
    *getBenchMark({ payload, callback }, { call, put, select }) {
      const res = yield call(api.getBenchMark, { page: { current: 1, pageSize: 1000 } });
      let benchData = [];
      if (res && res.code == '0') {
        res.data &&
          res.data.dataSource.forEach((element) => {
            benchData.push({
              value: element.benchId,
              title: element.benchName,
            });
          });
      } else {
        message.error((res && res.msg) || '获取基准失败!');
      }
      callback(benchData);
    },
  },

  reducers: {
    setState(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
